from flask_restful import Resource,reqparse
from controllers.robot.wraps import hmac_verify
from flask_babel import _
from controllers.robot import api
from services.weather.weather_service import WeatherService
class WeatherApi(Resource):
    @hmac_verify
    def post(self,):
        parser = reqparse.RequestParser()
        parser.add_argument("robot_id",type=str,required=True,location='json')
        parser.add_argument("location",type=str,required=False,default=None,location='json')
        parser.add_argument("ip_addr",type=str,required=True,location='json')
        args = parser.parse_args()
        robot_id = args["robot_id"]
        location = args.get("location")
        ip_addr = args["ip_addr"]
        return WeatherService.get_weather_by_robot(robot_id,location,ip_addr)
    
api.add_resource(WeatherApi, '/weather')